var express = require('express');
var router = express.Router();

var api = require("../../../utils/api");

//获取模板
router.get('/templates', function (req, res, next) {
    api.api.reqBody(req);
    var path = api.api.urltoPath(req.baseUrl) + "/templates.json";
    res.json(api.api.request(path));
});

//获取新增初始值
router.get('/initialdatas/0', function (req, res, next) {
    api.api.reqBody(req);
    var path = api.api.urltoPath(req.baseUrl) + "/initialdatas.json";
    res.json(api.api.request(path));
});
//提交客户
router.post('/0',function(req,res){
    api.api.reqBody(req);
    var path = api.api.urltoPath(req.baseUrl) + "/submit.json";
    res.json(api.api.request(path));
});

//删除客户
router.delete('/0',function(req,res){
    api.api.reqBody(req);
    var path = api.api.urltoPath(req.baseUrl) + "/submit.json";
    res.json(api.api.request(path));
});

//获取客户列表
router.get('/',function(req,res,next){
    var reqBody = JSON.parse(api.api.reqBody(req));
    var page = reqBody["page"];
    var path = api.api.urltoPath(req.baseUrl) + "/list" + page + ".json";
    res.json(api.api.request(path));
});

//获取客户详情
router.get('/details/1', function (req, res,next) {
    api.api.reqBody(req);
    var path = api.api.urltoPath(req.baseUrl) + "/detail.json";
    res.json(api.api.request(path));
  });

module.exports = router;